using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace PUCIT.eFCS.DataAccess.Models.Mapping
{
    public class formMap : EntityTypeConfiguration<form>
    {
        public formMap()
        {
            // Primary Key
            this.HasKey(t => t.formId);

            // Properties
            this.Property(t => t.progress)
                .IsRequired()
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("forms");
            this.Property(t => t.formId).HasColumnName("formId");
            this.Property(t => t.documentId).HasColumnName("documentId");
            this.Property(t => t.userId).HasColumnName("userId");
            this.Property(t => t.submitionDate).HasColumnName("submitionDate");
            this.Property(t => t.progress).HasColumnName("progress");
            this.Property(t => t.currentStation).HasColumnName("currentStation");

            // Relationships
            this.HasRequired(t => t.user)
                .WithMany(t => t.forms)
                .HasForeignKey(d => d.currentStation);
            this.HasRequired(t => t.user1)
                .WithMany(t => t.forms1)
                .HasForeignKey(d => d.userId);

        }
    }
}
